#include<iostream>
#include<mutex>
#include<condition_variable>
using namespace std;
mutex mtx;
condition_variable cv;
int flag = 1;
void print(int start, int end, int is_flag)
{
	for (int i = start; i <= end; i += 2) {
		unique_lock<mutex>lck(mtx);
		cv.wait(lck, [&]() {return flag == is_flag; });
		cout << i << " ";
		flag *= -1;
		cv.notify_one();
	}
}
int main()
{
	thread t1(print, 1, 99, 1);
	thread t2(print, 2, 100, -1);
	t1.join();
	t2.join();
	return 0;
}